﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Handrise.CDCable.Mobile.Business;

namespace Handrise.CDCable.Mobile.UI
{
    public partial class FormMain : FrmBase
    {
        Class1 test = new Class1();
        UserService userService = new UserService();
        NetService netService = new NetService();

        public FormMain()
        {
            InitializeComponent();

          //  userService.OnLoginComplete += new UserService.LoginCompleteHandler(userService_OnLoginComplete);
          //  netService.OnNetChange += new NetChangeHandler(netService_OnNetChange);
        }





        private void button2_Click(object sender, EventArgs e)
        {
            test.Test();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            test.TestDataLayer();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            test.TestBeginRecord();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            test.TestEndBeginRecord();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            test.TestStartPaly();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            test.TestPauseRecord();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            test.TestRestartRecord();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            test.TestStopPlay();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            test.TestPausePlay();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            test.TestRestartPlay();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            MessageBox.Show(test.TestCamera());
        }

        private void button12_Click(object sender, EventArgs e)
        {
            Synchronize s = new Synchronize();
            s.OnSynchronizeProcess += new SynchronizeProcessHandler(s_OnSynchronizeProcess);
            s.StartSynchronize();
        }

        void s_OnSynchronizeProcess(string info, int percent)
        {
            label1.Text = info + " " + percent + "%";
        }

        private void button13_Click(object sender, EventArgs e)
        {
            userService.Login("lizixin", "2008");
        }

        void userService_OnLoginComplete(bool isSuccess, User user)
        {
            if (isSuccess)
            {
                MessageBox.Show("登录成功,用户：" + user.UserName);
            }
            else
            {
                MessageBox.Show("登录失败");
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            AppLogic.gpsTraceService.OnDeviceStateChange += new GPSTraceService.DeviceStateChangeHandler(gpsTraceService_OnDeviceStateChange);
            AppLogic.gpsTraceService.Start();
        }

        void gpsTraceService_OnDeviceStateChange(string state)
        {
            label2.Text = state;
        }

        private void button15_Click(object sender, EventArgs e)
        {
            ////测试通过设备查找计划
            //PlanService planService = new PlanService();
            //planService.GetPlansByDevice(AppLogic.LoginUser.UserName, "24BD2055600010", "", "");

            //测试连接
            MessageBox.Show(netService.CurrentNetType.ToString());
            
        }

        void netService_OnNetChange(NetType newNetType)
        {
            MessageBox.Show(newNetType.ToString());
        }
    }
}